package com.base.video.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by weikailiang on 2020/2/24.
 */

public class MySeekBar extends android.support.v7.widget.AppCompatSeekBar{
    /**
     * 是否支持拖动进度
     */
    private boolean touch = true;
    public MySeekBar(Context context) {
        super(context);
    }

    public MySeekBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MySeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    public void setTouch(boolean touch) {
        this.touch = touch;
    }
    public boolean getTouch() {
        return touch;
    }

    /**
     * onTouchEvent 是在 SeekBar 继承的抽象类 AbsSeekBar
     */
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (touch) {
            return super.onTouchEvent(event);
        }
        return false;
    }
}

